﻿using System;

using SharpOSCAR.Base;

namespace SharpOSCAR.Snac.FEEDBAG
{
    /// <summary>
    /// This SNAC issues a query to the server for the client's Feedbag rights and to 
    /// let the system know what kind of Feedbag support it wants. 
    /// </summary>
    /// <remarks>
    /// This should be called before the FEEDBAG__QUERY SNAC and before the OSERVICE__CLIENT_ONLINE. 
    /// This is useful to figure out how many items are allowed for each class type. 
    /// </remarks>
    public class FEEDBAG__RIGHTS_QUERY : SNAC__Header
    {
        private TlvArray _Tlvs;

        /// <summary>
        /// Initialzes the FEEDBAG__RIGHTS_QUERY SNAC
        /// </summary>
        /// <param name="requestId">SNAC request ID</param>
        public FEEDBAG__RIGHTS_QUERY(uint requestId)
            : this(requestId, (FEEDBAG__RIGHTS_QUERY_FLAGS.ALIAS_ATTR_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.AUTHORIZATION_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.DOMAIN_SN_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.ICQ_NUM_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.INTERACTION_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.SMARTGRP_SUPPORTED |
                               FEEDBAG__RIGHTS_QUERY_FLAGS.SMS_NUM_SUPPORTED))
        { }

        /// <summary>
        /// Initialzes the FEEDBAG__RIGHTS_QUERY SNAC with the specified supported flags
        /// </summary>
        /// <param name="requestId">SNAC request ID</param>
        /// <param name="supportedFlags">Supported flags</param>
        public FEEDBAG__RIGHTS_QUERY(uint requestId, FEEDBAG__RIGHTS_QUERY_FLAGS supportedFlags)
            : base(19, 2, 0, requestId)
        {
            _Tlvs = new TlvArray();;
            Tlv rightsFlags = new Tlv(11, new U16((ushort)supportedFlags));
            _Tlvs.AddTlv(rightsFlags);
            SnacPayload = _Tlvs;
        }
    }
}
